import { reactive, onMounted, toRefs, ref, computed } from "vue";

import {
  getSchoolList, // 学校
  getGradeList, // 年级
  getClassList, // 班级
} from "@/api/common.js";

// 性别
const sexList = ref([
  {
    id: 1,
    name: "男",
  },
  {
    id: 0,
    name: "女",
  },
]);

export const getInitData = () => {
  const getdata = async () => {
    let dataSchool = await getSchoolList();
    let dataGrade = await getGradeList();
    let dataClass = await getClassList();
    dataSchool.data.forEach((o) => {
      o.name = o.schoolName;
    });
    dataGrade.data.forEach((o) => {
      o.name = o.gradeName;
    });
    dataClass.data.forEach((o) => {
      o.name = o.className;
    });
    return {
      schoolListData: dataSchool.data,
      gradeListData: dataGrade.data,
      classlListData: dataClass.data,
      sexListData:sexList.value
    };
  };
  return {
    getdata,
  };
};

export const getSchoolData = () => {
  const getdata = async () => {
    let dataSchool = await getSchoolList();
    dataSchool.data.forEach((o) => {
      o.name = o.schoolName;
    });
    return {
      schoolListData: dataSchool.data,
    };
  };
  return {
    getdata,
  };
};
